<!DOCTYPE html>
<html class="x-admin-sm">

<head>
<meta charset="UTF-8">
<title>欢迎页面-X-admin2.2</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="../../css/font.css">
<link rel="stylesheet" href="../../css/xadmin.css">
<script type="text/javascript" src="../../lib/layui/layui.js"
	charset="utf-8"></script>
<script type="text/javascript" src="../../js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
        <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
        <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md4">
				<form class="layui-form" action="">

					<div class="layui-form-item">
						<label class="layui-form-label">登录账户</label>
						<div class="layui-input-block">
							<input type="text" name="account" disabled="disabled"
								readonly="readonly" th:value="${obj== null?'':obj.account}"
								required lay-verify="required" autocomplete="off"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">旧的密码</label>
						<div class="layui-input-block">
							<input type="password" name="password"
								required lay-verify="required" autocomplete="off"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">新的密码</label>
						<div class="layui-input-block">
							<input type="password" name="newpass1" required
								lay-verify="required|newpass1" autocomplete="off"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">再次输入</label>
						<div class="layui-input-block">
							<input type="password" name="newpass2" required
								lay-verify="required|newpass2" autocomplete="off" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script>
		layui.use([ 'form', 'layer', 'upload' ], function() {
			$ = layui.jquery;
			var form = layui.form, layer = layui.layer;
			
			//修改密码
			form.on('submit(add)', function(data) {
				
				$.post("updateAdminPass",data.field,function(res){
					
					layer.msg(res.msg);
					if (res.success) {
						// 获得frame索引
 					}
					setTimeout(function(){
						xadmin.father_reload();
					},1000)
					
				})
				return false;
			});
			
			
			
			form.verify({
					newpass1: function(value, item){ //value：表单的值、item：表单的DOM对象
					
				    if(!/^[a-zA-Z]\w{5,16}$/.test(value)){
				      return '密码必须是字母开头不少于6位与数字的组合';
				    }
				  },
				  newpass2: function(value, item){ //value：表单的值、item：表单的DOM对象
					
				    if(!/^[a-zA-Z]\w{5,16}$/.test(value)){
					      return '密码必须是字母开头不少于6位与数字的组合';
					}
					if (value !=$("input[name='newpass1']").val() ) {
						return '与第一次键入的密码不相同';
					}
				  }
		});
	});
	</script>
</body>

</html>